﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WXYW.DAL;
using WXYW.Entities;

namespace WXYW.BLL
{
    public class LogisiticCompanyService: RepositoryBase
    {
        public void AddLogisticCompany(string name, string relation, string contact1, string phone1,
            string mobilePhone1, string fax1, string contact2, string phone2, string mobilePhone2,
            string fax2, string address, User currentOperator)
        {
            LogisticCompany logisticCompanyEntity = new LogisticCompany();
            logisticCompanyEntity.Address = address;
            logisticCompanyEntity.Contact1 = contact1;
            logisticCompanyEntity.Contact2 = contact2;
            logisticCompanyEntity.Fax1 = fax1;
            logisticCompanyEntity.Fax2 = fax2;
            logisticCompanyEntity.LastUpdated = DateTime.Now;
            logisticCompanyEntity.LastUpdatedBy = currentOperator.UserID;
            logisticCompanyEntity.MobilePhone1 = mobilePhone1;
            logisticCompanyEntity.MobilePhone2 = mobilePhone2;
            logisticCompanyEntity.Name = name;
            logisticCompanyEntity.Phone1 = phone1;
            logisticCompanyEntity.Phone2 = phone2;
            logisticCompanyEntity.Relation = relation;
            InsertEntity(logisticCompanyEntity);
        }

        public IQueryable<LogisticCompany> GetAllLogisticCompany()
        {
            return GetEntities<LogisticCompany>();
        }

        public LogisticCompany GetLogisticCompanyByID(int ID)
        {
            return GetEntities<LogisticCompany>(l => l.ID == ID).FirstOrDefault();
        }
    }
}
